package com.mt.controller;


import com.mt.constants.Result;
import com.mt.pojo.CinemaHall;
import com.mt.service.CinemaHallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Wang
 * @since 2020-12-11
 */
@RestController
public class CinemaHallController {
    @Autowired
    CinemaHallService hallService;

    @GetMapping("/hall/{cinemaId}")
    public Result pageAllHall(@RequestParam("currentPage")int currentPage,
                              @RequestParam("pageSize")int pageSize,
                              @RequestParam("hallName") String hallName,
                              @PathVariable Integer cinemaId){
        Result<Object> result = new Result<>();
        result.success(hallService.pageHall(currentPage,pageSize,hallName,cinemaId));
        return result;
    }

    @GetMapping("/hall/all")
    public Result listAllHall(@RequestParam("cinemaId") Integer cinemaId){
        Result<Object> result = new Result<>();
        result.success(hallService.listAllHall(cinemaId));
        return result;
    }

    @PostMapping("/hall/modify")
    public Result modifyHall(@RequestBody  CinemaHall hall){
        Result<Object> result = new Result<>();
        result.success(hallService.modifyHall(hall));
        return result;
    }

    @PostMapping("/hall/add")
    public Result insertHall(@RequestBody  CinemaHall hall){
        Result<Object> result = new Result<>();
        result.success(hallService.insertHall(hall));
        return result;
    }

    @PostMapping("/hall/delete")
    public Result deleteHall(@RequestBody  CinemaHall hall){
        Result<Object> result = new Result<>();
        result.success(hallService.deleteHall(hall));
        return result;
    }

    @GetMapping("/hall/detail")
    public Result getHallInfo(Integer hallId){
        Result<Object> result = new Result<>();
        result.success(hallService.getHallInfo(hallId));
        return result;
    }

}
